﻿@model ShipmentModel
@inject Grand.Services.Security.IPermissionService permissionService
@{
    //page title
    ViewBag.Title = T("Admin.Orders.Shipments.ViewDetails").Text;
    var canManageDocuments = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageDocuments);
    var canManageGenericAttributes = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageGenericAttributes);

}
<form asp-controller="Shipment" asp-action="ShipmentDetails" method="post">

    <script type="text/javascript">
        $(document).ready(function () {
            toggleShippedDate(false);
            toggleDeliveryDate(false);
        });

        function toggleShippedDate(editmode) {
            if (editmode) {
                $('#lblShippedDate').hide();
                $('#divShippedDate').show();
                $('#btnEditShippedDate').hide();
                $('#btnSaveShippedDate').show();
                $('#btnCancelShippedDate').show();
            }
            else {
                $('#lblShippedDate').show();
                $('#divShippedDate').hide();
                $('#btnEditShippedDate').show();
                $('#btnSaveShippedDate').hide();
                $('#btnCancelShippedDate').hide();
            }
        }

        function toggleDeliveryDate(editmode) {
            if (editmode) {
                $('#lblDeliveryDate').hide();
                $('#divDeliveryDate').show();
                $('#btnEditDeliveryDate').hide();
                $('#btnSaveDeliveryDate').show();
                $('#btnCancelDeliveryDate').show();
            }
            else {
                $('#lblDeliveryDate').show();
                $('#divDeliveryDate').hide();
                $('#btnEditDeliveryDate').show();
                $('#btnSaveDeliveryDate').hide();
                $('#btnCancelDeliveryDate').hide();
            }
        }
    </script>
    <div asp-validation-summary="All"></div>
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-truck"></i>
                        @T("Admin.Orders.Shipments.ViewDetails") - @Model.ShipmentNumber
                        <small>
                            <i class="fa fa-arrow-circle-left"></i>
                            @Html.ActionLink(T("Admin.Orders.Shipments.BackToList").Text, "List")
                        </small>
                    </div>
                    <div class="actions">
                        <div class="btn-group btn-group-devided">
                            <a href="@Url.Action("PdfPackagingSlip", new { shipmentId = Model.Id })" class="btn purple">
                                <i class="fa fa-file-pdf-o"></i> @T("Admin.Orders.Shipments.PrintPackagingSlip")
                            </a>
                            <span id="shipment-delete" class="btn red"><i class="fa fa-trash-o"></i> @T("Admin.Common.Delete")</span>
                            <vc:admin-widget widget-zone="order_shipment_details_buttons" additional-data="Model" />
                        </div>
                    </div>
                </div>
                <div class="x_content form">
                    <admin-tabstrip name="shipment-edit" SetTabPos="true">
                        <items>
                            <tabstrip-item text="@T("Admin.Orders.Shipments.ViewDetails.Info")" tab-index="0">
                                <content>
                                    <div>
                                        <partial name="_Info" model="Model" />
                                    </div>
                                </content>
                            </tabstrip-item>
                            @if (canManageDocuments)
                            {
                                <tabstrip-item text="@T("Admin.Orders.Shipments.Documents")" tab-index="1">
                                    <content>
                                        <div>
                                            <partial name="_Documents" model="Model" />
                                        </div>
                                    </content>
                                </tabstrip-item>
                            }
                            @if (canManageGenericAttributes)
                            {
                                <tabstrip-item text="@T("Admin.Common.GenericAttributes.Tab")" tab-index="2">
                                    <content>
                                        <div>
                                            <div class="form-actions">
                                                <input type="submit" value="@T("Admin.Common.Save")" id="btnSaveGenericAttributes" name="save-generic-attributes" class="k-button" />
                                            </div>
                                            <div class="form-horizontal">
                                                @{
                                                    ViewData["ObjectType"] = "Shipment";
                                                    ViewData["TabIndex"] = 2;
                                                 }
                                                <partial name="_GenericAttributes" model="Model" view-data="ViewData" />
                                            </div>
                                        </div>
                                    </content>
                                </tabstrip-item>
                            }
                            <vc:admin-widget widget-zone="shipment_details_tabs" additional-data="Model" />
                        </items>
                    </admin-tabstrip>
                </div>
            </div>

        </div>
    </div>
</form>
<admin-delete-confirmation button-id="shipment-delete" action-name="DeleteShipment" />
